package com.gy.assistant.ui.meeting;

import androidx.appcompat.app.AppCompatActivity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.stream.Collectors;

import im.zego.zim.entity.ZIMCallInfo;
import com.gy.assistant.R;

public class MeetingDetailActivity extends AppCompatActivity {
    public static void actionStart(Activity activity, ZIMCallInfo callInfo) {
        Intent intent = new Intent(activity, MeetingDetailActivity.class);
        intent.putExtra("caller",callInfo.caller);
        intent.putExtra("createTime",callInfo.createTime);

        List<String> userIdList = callInfo.callUserList.stream().map(zimCallUserInfo -> zimCallUserInfo.userID).collect(Collectors.toList());
        intent.putStringArrayListExtra("userList",new ArrayList<>(userIdList));
        activity.startActivity(intent);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        String caller = getIntent().getStringExtra("caller");
        long createTime = getIntent().getLongExtra("createTime",0);
        ArrayList<String> userIds = getIntent().getStringArrayListExtra("userList");

        setContentView(R.layout.activity_meeting_detail);
        TextView tvTitle = findViewById(R.id.tv_title);
        TextView tvCreateTime = findViewById(R.id.tv_createTime);
        TextView tvUsers = findViewById(R.id.tv_users);

        tvTitle.setText(String.format("%s的会议",caller));
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());
        String date = sdf.format(new Date(createTime));
        tvCreateTime.setText(String.format("创建时间：%s",date));

        tvUsers.setText(String.format("参会人员：%s", String.join("、", userIds)));

    }
}